package com.wonderful.mall.product.entity;

import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;

import java.io.Serializable;

import com.wonderful.common.validator.annotation.ListValue;
import com.wonderful.common.validator.group.AddGroup;
import com.wonderful.common.validator.group.UpdateGroup;
import com.wonderful.common.validator.group.UpdateStatusGroup;
import lombok.Data;
import org.hibernate.validator.constraints.URL;

import javax.validation.constraints.*;

/**
 * 品牌
 * 
 * @author BLITE
 * @email 1476995949@qq.com
 * @date 2022-09-10 12:31:45
 */
@Data
@TableName("pms_brand")
public class BrandEntity implements Serializable {
	private static final long serialVersionUID = 1L;

	/**
	 * 品牌id
	 */
	@TableId
	@NotNull(message = "修改必须指定id",groups = UpdateGroup.class)
	@Null(message = "新增不能指定id",groups = AddGroup.class)
	private Long brandId;
	/**
	 * 品牌名
	 */
	@NotBlank(groups = AddGroup.class)
	@NotNull(message = "修改必须指定品牌名",groups = { AddGroup.class,UpdateGroup.class})
	private String name;
	/**
	 * 品牌logo地址
	 */
	@NotEmpty(groups = AddGroup.class)
	@URL(message = "logo必须是一个合法的url地址",groups = { AddGroup.class,UpdateGroup.class})
	private String logo;
	/**
	 * 介绍
	 */
	private String descript;
	/**
	 * 显示状态[0-不显示；1-显示]
	 */
//	编写一个自定义校验注解ListValue
//	新建配置文件ValidationMessages.properties保存注解信息
//	编写一个自定义校验器ListValueConstraintValidator
//	关联自定义的校验器和自定义的校验注解（可以指定多个不同的校验器，适配不同类型的校验）
	@ListValue(value={0,1},groups = {AddGroup.class, UpdateStatusGroup.class})
	private Integer showStatus;
	/**
	 * 检索首字母
	 */
	@NotEmpty(groups = AddGroup.class)
	@Pattern(regexp = "^[a-zA-Z]$", message = "检索首字母必须是一个字母",groups = { AddGroup.class,UpdateGroup.class})
	private String firstLetter;
	/**
	 * 排序
	 */
	@NotNull(groups = AddGroup.class)
	@Min(value = 0, message = "排序必须大于等于0",groups = { AddGroup.class,UpdateGroup.class})
	private Integer sort;

}
